/**
 * Project:   dtu.fmes.googleloon
 * File:      JsonImporter.java
 * License: 
 *            This file is licensed under GNU General Public License version 3
 *            http://www.gnu.org/licenses/gpl-3.0.txt
 *
 * Copyright: Bartosz Cichecki [ cichecki.bartosz@gmail.com ]
 * Date:      Oct 5, 2013
 */

package dtu.fmes.loon.importer;

import java.io.FileReader;
import java.io.IOException;

import dtu.fmes.loon.model.SimulationState;
import dtu.fmes.loon.singletons.CurrentSimulationStateSingleton;
import dtu.fmes.loon.utils.GsonUtil;

/**
 * 
 * @author Bartosz Cichecki
 */
public class JsonImporter implements Importer {

	@Override
	public void doImport(String inputFile) throws IOException {
		CurrentSimulationStateSingleton currentSimulationState = CurrentSimulationStateSingleton.instance();

		try {
			SimulationState inputSimulationState = GsonUtil.buildGson().fromJson(new FileReader(inputFile), SimulationState.class);
			currentSimulationState.setSimulationState(inputSimulationState);
		} catch (IOException e) {
			e.printStackTrace();
			throw e;
		}
	}
}
